package run;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckPhoneNumber {
    Pattern compile =null;
    @BeforeEach
    public void setUp(){
         compile = Pattern.compile("1[0-9]{10}");
    }
    @Test
    public void check(){

        Matcher matcher = compile.matcher("173172 111");
        Assertions.assertFalse(matcher.find());

        Matcher matcher1 = compile.matcher("0122d");
        Assertions.assertFalse(matcher1.find());

        Matcher matcher2 = compile.matcher("17317298371");
        Assertions.assertTrue(matcher2.find());

        Matcher matcher3 = compile.matcher("173172983d1");
        Assertions.assertFalse(matcher3.find());

        Matcher matcher4 = compile.matcher("173172");
        Assertions.assertFalse(matcher4.find());

    }
}
